home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Applications 2002 November / SGI IRIX 6.5 Applications 2002 November.iso / dist / gateway.idb / usr / WebFace / Source / 20-NetworkServices / nsd / nsd-edit.cgi.z / nsd-edit.cgi
Encoding:
Text File  |  2002-06-12  |  5.9 KB  |  186 lines

  1. #!/usr/bin/perl5
  2. #
  3. # nsd-edit.frm
  4. #
  5. # Copyright 1988-1996 Silicon Graphics, Inc.
  6. # All rights reserved.
  7. #
  8. # This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  9. # the contents of this file may not be disclosed to third parties, copied or
  10. # duplicated in any form, in whole or in part, without the prior written
  11. # permission of Silicon Graphics, Inc.
  12. #
  13. # RESTRICTED RIGHTS LEGEND:
  14. # Use, duplication or disclosure by the Government is subject to restrictions
  15. # as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  16. # and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  17. # successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  18. # rights reserved under the Copyright Laws of the United States.
  19. #
  20.  
  21. BEGIN { require "/usr/WebFace/lib/CGI.pm"; import CGI; }
  22. require "/usr/OnRamp/lib/OnRamp.pm";
  23. require "/usr/OnRamp/lib/java.pm";
  24.  
  25. $query = new CGI;
  26.  
  27. $title        = "Unified Name Service";
  28. $myname       = "nsd-edit.cgi";
  29. $help_page    = "nsd-config-help.html";
  30. $conf_page    = "/admin/nsd-config.cgi";
  31.  
  32.  
  33. $js =
  34. "$js_standard
  35. $js_help
  36. $js_error_box
  37. function checkForm(form) {
  38.         return (true);
  39. }";
  40.  
  41.  
  42. if ($query->param) {
  43.     @names = $query->param;
  44.     $num_new = $query->param('num_new');
  45.     $total_libs = $query->param('total_libs');
  46.     if ($#names == $total_libs+2) {                      
  47.         if ($num_new <= 0) { # No changes
  48.             &redirect($conf_page);
  49.             exit;
  50.         } else {                             # Just adding maps
  51.             $instructions = "<blockquote>
  52.                 Please enter the name of each new map in the space
  53.                 provided and choose its order of lookup services.  
  54.                 When you're done, use the \"Ok\" button.  
  55.                 </blockquote><p>\n";
  56.         }
  57.     } else {
  58.         if ($num_new > 0) {   # Changing and adding 
  59.             $instructions = "<blockquote>Enter the name of each 
  60.             new map in the space provided and choose the order of 
  61.             lookup services for all maps.  When you're done, use the 
  62.             \"Ok\" button to view your changes.  </blockquote><p>\n";
  63.         } else {                              # Just changing
  64.             $instructions = "<blockquote>Please choose the order 
  65.             of lookup services for each map.  When you're done, 
  66.             use the \"Ok\" button to view your changes. 
  67.             </blockquote><p>\n";
  68.         }
  69.     }
  70.  
  71.     print $query->header;
  72.     &list_libraries;
  73.     &generic;
  74.  
  75. } else {
  76.     redirect($conf_page);
  77.     exit;
  78. }
  79.  
  80. sub list_libraries {
  81.     local (@files);
  82.     opendir (NSLIBS, "/var/ns/lib");
  83.     @files = grep(!/^\./, readdir(NSLIBS));
  84.     closedir(NSLIBS);
  85.     foreach $file (@files) {
  86.         undef $symlink;
  87.         $symlink = true if (-l "/var/ns/lib/$file");
  88.         $file =~ s/^libns_//g;
  89.         $file =~ s/\.\w*$//g;
  90.         push (@choices,$file) if (! $symlink);
  91.     }
  92.     push (@choices,"none");
  93. }
  94.  
  95. sub generic {
  96.     &js_title_block($title,$js);
  97.     &header_block($title);
  98.  
  99.     # Check if just deleting maps
  100.     foreach $map (@names) {
  101.         push (@edit, $map)
  102.             if ($map !~ /^doit$/ && $map !~ /^num_new$/ &&
  103.                 $map !~ /^total_libs$/ && $map !~ /_lib\d+$/ &&
  104.                 $map !~ /^del_/);
  105.     }
  106.     if (! @edit && $num_new < 1) {
  107.         $instructions = "These are the maps you chose to delete.  Use "
  108.                       . "the \"Ok\" button to delete them from your UNS "
  109.                       . "configuration file.";
  110.     }
  111.  
  112.     # Print form header
  113.     print $query->startform("POST", "summary.cgi", "", 
  114.           "NAME=StandardForm", "onSubmit=\"return runSubmit()\"");
  115.     print $instructions;
  116.     print qq|<font size="+1"><center><table>\n|;
  117.     print "<tr><th><th>First<th>Next<th>Last</tr>\n" if (@edit || $num_new > 0);
  118.  
  119.     # Changing existing maps
  120.     foreach $map (@names) {
  121.         next if ($map =~ /^doit$/);
  122.         next if ($map =~ /^num_new$/);
  123.         next if ($map =~ /^total_libs$/);
  124.         next if ($map =~ /_lib\d+$/);
  125.  
  126.         if ($map =~ /^del_/) {
  127.             $map =~ s/del_//g;
  128.             $hidden .= "<input type=hidden name=$map value=delete>\n";
  129.             push (@delete, $map);
  130.             next;
  131.         }
  132.  
  133.         for ($i = 0; $i < 3; $i++) {
  134.             $libname = $map . "_lib" . $i;
  135.             $order[$i] = $query->param($libname);
  136.             $order[$i] = "none" if (! $order[$i]);
  137.         }
  138.         $order[0] = "files" if ($order[0] eq "none");
  139.  
  140.         print "<tr><td align=left><b>$map: </b>\n";
  141.         for ($j = 1; $j < 4; $j++) {
  142.             $name = $map . "_" . $j;
  143.             print "<td align=center>", $query->popup_menu(-name=>"$name",
  144.                             -values=>\@choices,
  145.                             -default=>$order[$j-1]);
  146.             $name = "old_" . $map . "_" . $j;
  147.             print "<input type=hidden name=$name value=\"$order[$j-1]\">\n\n";
  148.         }
  149.     }
  150.  
  151.     # Adding new maps
  152.     if ($num_new > 0) {
  153.         @order = ("files", "none", "none"); 
  154.         print qq|<input type=hidden name=num_new value="$num_new">\n|;
  155.         for ($i = 0; $i < $num_new; $i++) {
  156.             print "<tr><td align=left>";
  157.             $name = "new" . $i . "_name";
  158.             print qq|<b><input name="$name" size=10>:</b>\n|;
  159.             for ($j = 1; $j < 4; $j++) {
  160.                 $name = "new" . $i . "_" . $j;
  161.                 print "<td align=center>", $query->popup_menu(-name=>"$name",
  162.                                 -values=>\@choices,
  163.                                 -default=>$order[$j-1]);
  164.             }
  165.         }
  166.     }
  167.  
  168.     # Deleting existing maps
  169.     if (@delete) {
  170.         print "<tr><td colspan=4><br>";
  171.         print "<b><i>Maps to be deleted:</i></b>\n";
  172.         foreach $map (@delete) {
  173.             print "<tr><td><b>$map</b>\n";
  174.         }
  175.     }
  176.     print $hidden;
  177.     print "</tr>";
  178.     print "</table></center>";
  179.     print "<p>\n";
  180.  
  181.     print &js_buttons('doit','Ok','onClick="markOK()"','onClick="markOther()"',
  182.         "onClick=\"do_help('$help_page'); return (false)\"");
  183.  
  184.     print $query->endform;
  185. }
  186.